package com.wtwd.campus.send;

import com.wtwd.campus.common.Constants;
import com.wtwd.campus.entity.Command;
import com.wtwd.campus.entity.MqMessage;
import com.wtwd.campus.entity.MqSleepTimeAutoChange;

public class AutoChangeWorkModeSender implements Sender {
    @Override
    public Command dealMessage(MqMessage mqMessage) {
        // *WT,IMEI, SLEEPTIME,130305,22:00,23:00,1#
        MqSleepTimeAutoChange mqSleepTimeAutoChange = (MqSleepTimeAutoChange)mqMessage.getObject();
        String start = mqSleepTimeAutoChange.getStart();   // 开始时间  22:00
        String end = mqSleepTimeAutoChange.getEnd();   // 结束时间  02:00
        String commandNumber = mqSleepTimeAutoChange.getCommandNumber();   // 指令序列号
        String imei = mqSleepTimeAutoChange.getImei();  // imei号
        Integer flag = mqSleepTimeAutoChange.getFlag();  // flag 功能开关 0-关闭 1-开启
        // 拼接command指令
        Command command = new Command();
        command.setImei(imei);
        command.setCommandNumber(commandNumber);
        command.setStatus(Constants.COMMAND_NEED_SAVE);
        // 拼接指令
        String commandContent = "*".concat(Constants.MANUFACTURER_NAME).concat(",").concat(imei).concat(",").concat(Constants.AUTO_CHANGE_WORK_MODE).concat(",").concat(commandNumber).concat(",").concat(start).concat(",").concat(end).concat(",").concat(String.valueOf(flag)).concat("#");
        command.setContent(commandContent);
        command.setCmd(Constants.AUTO_CHANGE_WORK_MODE);
        // 重发次数以及发送时间统一在send的时候处理
        return command;
    }
}
